Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): recursive resolve deps on create command graph #22989

Merged
merged 1 commit into from
Jul 5, 2024

Conversation

Naymi
Copy link
Contributor

@Naymi Naymi commented Apr 24, 2024

introductory

image

Current Behavior

nx exec --projects=my-node-app -- pwd
TypeError: graph.dependencies[id] is not iterable
    at _findCycle (/Users/anatolijfedorov/prjcts/tmp/nx-nest-workspace/node_modules/nx/src/tasks-runner/task-graph-utils.js:8:39)
    at _findCycle (/Users/anatolijfedorov/prjcts/tmp/nx-nest-workspace/node_modules/nx/src/tasks-runner/task-graph-utils.js:11:23)
    at findCycle (/Users/anatolijfedorov/prjcts/tmp/nx-nest-workspace/node_modules/nx/src/tasks-runner/task-graph-utils.js:23:23)
    at createCommandGraph (/Users/anatolijfedorov/prjcts/tmp/nx-nest-workspace/node_modules/nx/src/commands-runner/create-command-graph.js:25:52)
    at getCommandProjects (/Users/anatolijfedorov/prjcts/tmp/nx-nest-workspace/node_modules/nx/src/commands-runner/get-command-projects.js:7:72)
    at runScriptAsNxTarget (/Users/anatolijfedorov/prjcts/tmp/nx-nest-workspace/node_modules/nx/src/command-line/exec/exec.js:60:73)
    at Object.nxExecCommand (/Users/anatolijfedorov/prjcts/tmp/nx-nest-workspace/node_modules/nx/src/command-line/exec/exec.js:44:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.handler (/Users/anatolijfedorov/prjcts/tmp/nx-nest-workspace/node_modules/nx/src/command-line/exec/command-object.js:11:13)

Expected Behavior

nx exec --projects=my-node-app -- pwd
/tmp/nx-nest-workspace/my-node-lib-2
/tmp/nx-nest-workspace/my-node-lib
/tmp/nx-nest-workspace/apps/my-node-app

Fixes #22994
Added function that resolves dependencies recursively

@Naymi Naymi requested a review from a team as a code owner April 24, 2024 22:05
@Naymi Naymi requested a review from AgentEnder April 24, 2024 22:05
Copy link

vercel bot commented Apr 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Jul 5, 2024 2:43am

@xiongemi
Copy link
Collaborator

is there a link to your project with above project graph? i want to test it out.

@Naymi
Copy link
Contributor Author

Naymi commented May 17, 2024

is there a link to your project with above project graph? i want to test it out.

Yeah, https://github.com/Naymi/nx-exec-recursive-demo

more details here #22994

@xiongemi xiongemi changed the title fix[nx]: recursive resolve deps on create command graph fix(nx): recursive resolve deps on create command graph May 17, 2024
@vaharoni
Copy link

vaharoni commented May 19, 2024

This fix seems to run the command on the project's dependencies as well:

$ nx exec -p my-node-app -- pwd
/Users/me/workspace/nx-exec-recursive-demo/my-node-lib-2
/Users/me/workspace/nx-exec-recursive-demo/my-node-lib
/Users/me/workspace/nx-exec-recursive-demo/apps/my-node-app

I would expect it to work on the specified project only and therefore output just the last line above. Now, I'm completely new to Nx, so could be wrong with the intent behind nx exec. But I think I saw in the documentation that the task graph and project graph aren’t necessarily isomorphic, as this fix seems to force (if we equate the commands being executed with tasks).

@xiongemi xiongemi changed the title fix(nx): recursive resolve deps on create command graph fix(core): recursive resolve deps on create command graph Jul 5, 2024
@xiongemi xiongemi merged commit e15479b into nrwl:master Jul 5, 2024
6 checks passed
FrozenPandaz pushed a commit that referenced this pull request Jul 5, 2024
## introductory
<img width="620" alt="image"
src="https://github.com/nrwl/nx/assets/21343944/1ef5e2a2-0f65-4fde-aa7d-b52152af59a7">

## Current Behavior

```shell
nx exec --projects=my-node-app -- pwd
TypeError: graph.dependencies[id] is not iterable
    at _findCycle (/Users/anatolijfedorov/prjcts/tmp/nx-nest-workspace/node_modules/nx/src/tasks-runner/task-graph-utils.js:8:39)
    at _findCycle (/Users/anatolijfedorov/prjcts/tmp/nx-nest-workspace/node_modules/nx/src/tasks-runner/task-graph-utils.js:11:23)
    at findCycle (/Users/anatolijfedorov/prjcts/tmp/nx-nest-workspace/node_modules/nx/src/tasks-runner/task-graph-utils.js:23:23)
    at createCommandGraph (/Users/anatolijfedorov/prjcts/tmp/nx-nest-workspace/node_modules/nx/src/commands-runner/create-command-graph.js:25:52)
    at getCommandProjects (/Users/anatolijfedorov/prjcts/tmp/nx-nest-workspace/node_modules/nx/src/commands-runner/get-command-projects.js:7:72)
    at runScriptAsNxTarget (/Users/anatolijfedorov/prjcts/tmp/nx-nest-workspace/node_modules/nx/src/command-line/exec/exec.js:60:73)
    at Object.nxExecCommand (/Users/anatolijfedorov/prjcts/tmp/nx-nest-workspace/node_modules/nx/src/command-line/exec/exec.js:44:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.handler (/Users/anatolijfedorov/prjcts/tmp/nx-nest-workspace/node_modules/nx/src/command-line/exec/command-object.js:11:13)

```

## Expected Behavior

```shell
nx exec --projects=my-node-app -- pwd
/tmp/nx-nest-workspace/my-node-lib-2
/tmp/nx-nest-workspace/my-node-lib
/tmp/nx-nest-workspace/apps/my-node-app
```

Fixes #22994
Added function that resolves dependencies recursively

Co-authored-by: afedorov <afedorov@rvision.ru>
(cherry picked from commit e15479b)
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: graph.dependencies[id] is not iterable
3 participants